package 实现多线程;

public class 线程的相关控制2 {
    public static void main(String[] args) {
        ThreadJoin tj1 = new ThreadJoin();
        ThreadJoin tj2 = new ThreadJoin();
        ThreadJoin tj3 = new ThreadJoin();
        tj1.setName("康熙");
        tj2.setName("四阿哥");
        tj3.setName("八阿哥");
        tj1.start();
        try {
            /*等待这个线程死亡之后，才去执行后面的线程*/
            tj1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        tj2.start();
        tj3.start();
    }
}
class ThreadJoin extends Thread{
    public void run(){
        for (int i = 0; i < 100; i++) {
            System.out.println(getName()+":"+i);
        }
    }
}